import 'package:flutter/material.dart';

import 'osc_medal_entity.dart';
import 'osc_user_identity.dart';

class OscUser {
	bool bindTel;
	int gender;//1：男，2：女，
	OscUserIdentity identity;
	OscUserMore more;
	String name;
	List<int> blacklist;
	bool inBlacklist;
	int id;
	String portrait;
	String desc;
	int relation;//0:黑名单,1:相互关注, 2:关注, 3:粉丝, 4:无
	OscUserStatistics statistics;

	bool checked = false;
	Color color = Colors.transparent;

	OscUser({this.bindTel, this.gender, this.identity, this.more, this.name, this.blacklist, this.inBlacklist, this.id, this.portrait, this.desc, this.relation, this.statistics});

	OscUser.fromJson(Map<String, dynamic> json) {
		bindTel = json['bindTel'];
		gender = json['gender'];
		identity = json['identity'] != null ? new OscUserIdentity.fromJson(json['identity']) : null;
		more = json['more'] != null ? new OscUserMore.fromJson(json['more']) : null;
		name = json['name'];
		blacklist = json['blacklist']?.cast<int>();
		inBlacklist = json['inBlacklist'];
		id = json['id'];
		portrait = json['portrait'];
		desc = json['desc'];
		relation = json['relation'];
		statistics = json['statistics'] != null ? new OscUserStatistics.fromJson(json['statistics']) : null;
	}

	Map<String, dynamic> toJson() {
		final Map<String, dynamic> data = new Map<String, dynamic>();
		data['bindTel'] = this.bindTel;
		data['gender'] = this.gender;
		if (this.identity != null) {
      data['identity'] = this.identity.toJson();
    }
		if (this.more != null) {
      data['more'] = this.more.toJson();
    }
		data['name'] = this.name;
		data['blacklist'] = this.blacklist;
		data['inBlacklist'] = this.inBlacklist;
		data['id'] = this.id;
		data['portrait'] = this.portrait;
		data['desc'] = this.desc;
		data['relation'] = this.relation;
		if (this.statistics != null) {
      data['statistics'] = this.statistics.toJson();
    }
		return data;
	}
}


class OscUserMore {
	List<OscMedal> medals;
	List<double> radar;
	String joinDate;
	List<int> field;
	String province;
	String city;
	List<int> skill;
	String company;
	String expertise;
	String platform;

	OscUserMore({this.medals, this.radar, this.joinDate, this.field, this.province, this.city, this.skill, this.company, this.expertise, this.platform});

	OscUserMore.fromJson(Map<String, dynamic> json) {
		if (json['medals'] != null) {
			medals = new List<OscMedal>();(json['medals'] as List).forEach((v) { medals.add(new OscMedal.fromJson(v)); });
		}
		radar = json['radar']?.cast<double>();
		joinDate = json['joinDate'];
		field = json['field']?.cast<int>();
		province = json['province'];
		city = json['city'];
		skill = json['skill']?.cast<int>();
		company = json['company'];
		expertise = json['expertise'];
		platform = json['platform'];
	}

	Map<String, dynamic> toJson() {
		final Map<String, dynamic> data = new Map<String, dynamic>();
		if (this.medals != null) {
      data['medals'] =  this.medals.map((v) => v.toJson()).toList();
    }
		data['radar'] = this.radar;
		data['joinDate'] = this.joinDate;
		data['field'] = this.field;
		data['province'] = this.province;
		data['city'] = this.city;
		data['skill'] = this.skill;
		data['company'] = this.company;
		data['expertise'] = this.expertise;
		data['platform'] = this.platform;
		return data;
	}
}

/*class OscUserMoreMedal {
	String obtainCondition;
	String obtainDate;
	String lightLargeLogo;
	bool xShow;
	String title;
	int type;
	bool canApplyFor;
	String grayLargeLogo;
	String intro;
	int id;
	String lightLogo;
	int category;
	String grayLogo;
	int applyStatus;

	OscUserMoreMedal({this.obtainCondition, this.lightLargeLogo, this.xShow, this.title, this.type, this.canApplyFor, this.grayLargeLogo, this.intro, this.obtainDate, this.id, this.lightLogo, this.category, this.grayLogo, this.applyStatus});

	OscUserMoreMedal.fromJson(Map<String, dynamic> json) {
		obtainCondition = json['obtainCondition'];
		lightLargeLogo = json['lightLargeLogo'];
		xShow = json['show'];
		title = json['title'];
		type = json['type'];
		canApplyFor = json['canApplyFor'];
		grayLargeLogo = json['grayLargeLogo'];
		intro = json['intro'];
		obtainDate = json['obtainDate'];
		id = json['id'];
		lightLogo = json['lightLogo'];
		category = json['category'];
		grayLogo = json['grayLogo'];
		applyStatus = json['applyStatus'];
	}

	Map<String, dynamic> toJson() {
		final Map<String, dynamic> data = new Map<String, dynamic>();
		data['obtainCondition'] = this.obtainCondition;
		data['lightLargeLogo'] = this.lightLargeLogo;
		data['show'] = this.xShow;
		data['title'] = this.title;
		data['type'] = this.type;
		data['canApplyFor'] = this.canApplyFor;
		data['grayLargeLogo'] = this.grayLargeLogo;
		data['intro'] = this.intro;
		data['obtainDate'] = this.obtainDate;
		data['id'] = this.id;
		data['lightLogo'] = this.lightLogo;
		data['category'] = this.category;
		data['grayLogo'] = this.grayLogo;
		data['applyStatus'] = this.applyStatus;
		return data;
	}
}*/

class OscUserStatistics {
	int score;
	int answer;
	int honorScore;
	int activeScore;
	int tweet;
	int blog;
	int follow;
	int collect;
	int discuss;
	int fans;

	OscUserStatistics({this.score, this.answer, this.honorScore, this.activeScore, this.tweet, this.blog, this.follow, this.collect, this.discuss, this.fans});

	OscUserStatistics.fromJson(Map<String, dynamic> json) {
		score = json['score'];
		answer = json['answer'];
		honorScore = json['honorScore'];
		activeScore = json['activeScore'];
		tweet = json['tweet'];
		blog = json['blog'];
		follow = json['follow'];
		collect = json['collect'];
		discuss = json['discuss'];
		fans = json['fans'];
	}

	Map<String, dynamic> toJson() {
		final Map<String, dynamic> data = new Map<String, dynamic>();
		data['score'] = this.score;
		data['answer'] = this.answer;
		data['honorScore'] = this.honorScore;
		data['activeScore'] = this.activeScore;
		data['tweet'] = this.tweet;
		data['blog'] = this.blog;
		data['follow'] = this.follow;
		data['collect'] = this.collect;
		data['discuss'] = this.discuss;
		data['fans'] = this.fans;
		return data;
	}
}
